﻿@using Property;
@{
    ViewBag.Title = "ComponentList";
}
@model string
@section head
{
    <link href="@Url.Content("~/ScriptPlugin/easyui/themes/gray/easyui.css")" rel="stylesheet" />
    <link href="@Url.Content("~/ScriptPlugin/easyui/themes/icon.css")" rel="stylesheet" />
    <script type="text/javascript" src="@Url.Content("~/ScriptPlugin/easyui/jquery.easyui.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/ScriptPlugin/easyui/locale/easyui-lang-zh_CN.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/ScriptPlugin/easyui/plugins/datagrid-groupview.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/ScriptPlugin/easyui/plugins/datagrid-detailview.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/KingsSharp.DataGrid.Filter.js")"></script>
    <link href="@Url.Content("~/App_Themes/default/icons/iconcontent/iconfont.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/App_Themes/default/icons/iconcontent/demo.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/ScriptPlugin/ztree/js/jquery.ztree.core-3.5.js")" type="text/javascript"></script>
    <link href="@Url.Content("~/ScriptPlugin/ztree/css/zTreeStyle/zTreeStyle.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery.linq.min.js")"></script>
}
<div id="grid">
    <div id="toolpannel">
        <div class="content-pannel-buttons">
   
            <a onclick="ComponentEdit()"><b class="p-icon-edit">编辑</b></a>

            <a onclick="ComponentDelete()"><b class="p-icon-delete">删除</b></a>
        </div>
    </div>

    <input type="hidden" data-filter="true" id="ProductId" name="ProductId" value="@ViewBag.ProductId" />
</div>
@section foot
{
    <script type="text/javascript">
        function LoadGridData() {
            var columns = [[
                { field: "ck", checkbox: true },
                { field: "Name", title: "零件名称", width: 120 },
                { field: "Size", title: "尺寸", width: 120 },
                { field: "DownSize", title: "下料尺寸", width: 120 }
            ]];
            var parameter = {
                title: null,
                columns: columns,
                url: "@Url.Content("~/Customer/Product/GetComponentGridData")",
                pageNumber: 1
            };
            var grid = KingsSharp.GetGridData("#grid", parameter).Grid;
        }
        LoadGridData();
        //删除明细
          function ComponentDelete() {
                var row = $("#grid").datagrid("getSelected");
                if (row == null) {
                    K.Alert("请选择需删除的零件");
                    return false;
                }
                K.Confirm("确认删除零件 \"" + row.Name + "\" ？", function () {
                    K.AjaxJson("@Url.Content("~/Customer/Product/ComponentDelete")", { UserId: row.Id, UserName: row.Name }, function (result) {
                        if (K.ShowOrAlert(result)) {
                            $("#grid").datagrid("load");
                        }
                    }, "零件 \"" + row.Name + "\"删除中...");
                });
          }
        //编辑明细
        function ComponentEdit() {
            var row = $("#grid").datagrid("getSelected");
            if (row == null) {
                K.Alert("请选择需编辑的行");
                return false;
            }
            K.layer.iframe({
                title: "@Html.GetLayerTitle(LayerIcon.Edit,"编辑明细")",
                content: "@Url.Content("~/Customer/Product/ComponentEdit")?ComponentId=" + row.Id,
            maxmin: true,
            initfull: true,
            btn: ["保存", "返回"],
            callback: function (result) {
                if (K.ShowOrAlert(result)) {
                    $("#grid").datagrid("load");
                }
            }
        });
        }
    </script>
}


